package org.ic992929.SbStart;

import org.ic992929.SbStart.config.WiselySettings;
import org.springframework.boot.Banner;
import org.springframework.boot.context.embedded.MultipartConfigFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;
import simple.plugin.spring.SpringUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.servlet.MultipartConfigElement;

@SpringBootApplication
@EnableScheduling
@ServletComponentScan
@Import(value={SpringUtil.class})
@EnableConfigurationProperties({WiselySettings.class})
public class SbStartApplication {

  /**注册Spring Util
   * 这里为了和上一个冲突，所以方面名为：springUtil2
   * 实际中使用springUtil
   */
  @Bean
  public SpringUtil springUtil2(){return new SpringUtil();}

  @Bean
  public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    //// 设置文件大小限制 ,超了，页面会抛出异常信息，这时候就需要进行异常信息的处理了;
    factory.setMaxFileSize("128KB"); //KB,MB
    /// 设置总上传数据总大小
    factory.setMaxRequestSize("256KB");
    //Sets the directory location where files will be stored.
    //factory.setLocation("路径地址");
    return factory.createMultipartConfig();
  }

  public static void main(String[] args) {
    /*SpringApplication application = new SpringApplication(SbStartApplication.class);
        *//*
         * Banner.Mode.OFF:关闭;
         * Banner.Mode.CONSOLE:控制台输出，默认方式;
         * Banner.Mode.LOG:日志输出方式;
         *//*
    application.setBannerMode(Banner.Mode.OFF);
    application.run(args);*/
    SpringApplication.run(SbStartApplication.class,  new String[]{"hello,","林峰"});
  }
}